package com.kiln.juxingqs.ui

import android.view.View
import androidx.navigation.fragment.NavHostFragment
import com.kiln.juxingqs.BaseMiddleActivity
import com.kiln.juxingqs.R
import com.kiln.juxingqs.databinding.ActivityMyGuadanBinding
import com.kiln.juxingqs.databinding.ActivityXyzrNewBinding
import com.kiln.juxingqs.ui.vm.GuadanViewModel
import com.kiln.juxingqs.ui.vm.XyzrViewModel

/**
 * 我的挂单
 */
class MyGuaDanActivity :
    BaseMiddleActivity<GuadanViewModel, ActivityMyGuadanBinding>() {

//    var titleName: String? = null
//    var detail_type: String? = null
    var goods_id: String? = null
    var isTabGone: Boolean = false

    override fun getLayout(): Int {
        return R.layout.activity_my_guadan
    }

    override fun initViewModel(): GuadanViewModel = createViewModel()

    override fun initView() {
        binding.event = this
        binding.vm = viewModel
//        titleName = intent.getStringExtra("titleName")
//        detail_type = intent.getStringExtra("detail_type")
        goods_id = intent.getStringExtra("goods_id")
//        detail_type?.let {
//            isTabGone = it.equals("20") || it.equals("21") || it.equals("22") || it.equals("23")
//        }

    }

    fun clickTab(index: Int) {
        updateTab(index)

    }

    fun updateTab(index: Int) {
        when (index) {
            1 -> {
                binding.oneTab.isSelected = true
                binding.twoTab.isSelected = false
                binding.one.visibility = View.VISIBLE
                binding.two.visibility = View.GONE
                (supportFragmentManager.findFragmentById(
                    R.id.fragment
                ) as NavHostFragment).navController.navigate(
                    R.id.oneTab
                )
            }
            0 -> {
                binding.oneTab.isSelected = false
                binding.twoTab.isSelected = true
                binding.one.visibility = View.GONE
                binding.two.visibility = View.VISIBLE
                (supportFragmentManager.findFragmentById(
                    R.id.fragment
                ) as NavHostFragment).navController.navigate(
                    R.id.twoTab
                )
            }

        }
    }

    override fun initData() {
        updateTab(intent.getIntExtra("index", 1))
    }

}